//
//  CHSAnimationLayer.m
//  ZXAnimationUtil_Example
//
//  Created by 朱新明 on 2023/7/15.
//  Copyright © 2023 simon. All rights reserved.
//

#import "CHSAnimationLayer.h"

@implementation CHSAnimationLayer

///当我们修改了CALayer 的某个属性时（不限于可动画的属性），都会触发一个图层动作。
///图层动作对象通过 CALayer 实例的ActionForKey方法获取，这个方法在查找对应的动作对象时有4条规则：
- (nullable id<CAAction>)actionForKey:(NSString *)event{
    id action = [super actionForKey:event];
    return action;
}


+ (nullable id<CAAction>)defaultActionForKey:(NSString *)event{
    id action = [super defaultActionForKey:event];
    return action;
}

//设置contents方式提供位图
- (void)display{
    
    self.contents = (__bridge id _Nullable)(([UIImage imageNamed:@"keyframing_2"]).CGImage);
}

///图形上下文方式：在位图图像上下文提供位图
- (void)drawInContext:(CGContextRef)ctx{
    
    UIImage *image = [UIImage imageNamed:@"keyframing_2x"];
    [image drawInRect:CGRectMake(0, 0, 100, 100)];
    UIGraphicsEndImageContext();
}

@end
